package com.baoxin.chenxixc4coach;

import android.content.Intent;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.baoxin.chenxixc4coach.adapter.MyViewPagerAdapter;
import com.baoxin.chenxixc4coach.fragments.TitleFragment;
import com.baoxin.chenxixc4coach.fragments.student.GraduateFragment;
import com.baoxin.chenxixc4coach.fragments.student.SubjecFragment;
import com.yusheng.w.tablayout.widgets.XTabLayout;

import java.util.ArrayList;
import java.util.List;

import q.rorbin.badgeview.Badge;
import q.rorbin.badgeview.QBadgeView;

public class TestRangeActivity extends BaseActivity implements XTabLayout.OnTabSelectedListener {
    List<TitleFragment> fragments = new ArrayList<>(5);
    XTabLayout tabLayout;
    ViewPager viewPager;
    SubjecFragment subjecFragment1;//科目1
    SubjecFragment subjecFragment2;
    SubjecFragment subjecFragment3;
    SubjecFragment subjecFragment4;
    GraduateFragment graduateFragment;//毕业

    ImageView mAddStudent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_student);

        tabLayout = findViewById(R.id.tab_student);
        viewPager = findViewById(R.id.view_pager);
        mAddStudent = findViewById(R.id.add_student);
        Badge q = new QBadgeView(activity).bindTarget(mAddStudent);
        q.setBadgeText("");//红点
        mAddStudent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(activity, UncheckedStudentActivity.class);
                startActivity(intent);
            }
        });


        subjecFragment1 = new SubjecFragment();
        subjecFragment2 = new SubjecFragment();
        subjecFragment3 = new SubjecFragment();
        subjecFragment4 = new SubjecFragment();
        graduateFragment = new GraduateFragment();
        subjecFragment1.setSubject_type(1);
        subjecFragment2.setSubject_type(2);
        subjecFragment3.setSubject_type(3);
        subjecFragment4.setSubject_type(4);
        fragments.add(subjecFragment1);
        fragments.add(subjecFragment2);
        fragments.add(subjecFragment3);
        fragments.add(subjecFragment4);
        fragments.add(graduateFragment);

        viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), fragments));
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setOnTabSelectedListener(this);

    }

    @Override
    public void onTabSelected(XTabLayout.Tab tab) {
        viewPager.setCurrentItem(tab.getPosition());
    }

    @Override
    public void onTabUnselected(XTabLayout.Tab tab) {

    }

    @Override
    public void onTabReselected(XTabLayout.Tab tab) {

    }


}
